package com.project.controller;

import com.github.pagehelper.PageInfo;
import com.project.service.ISaleCountService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;

/**
 * @author lyl
 * description:
 */
@RestController
@RequestMapping("saleCount")
@Api(tags = "销售统计")
public class SaleCountController {
    @Autowired
    private ISaleCountService iSaleCountService;

    @GetMapping("showByPage/{pageNum}/{factory}/{startDate}/{endDate}")
    private PageInfo showByPage(@PathVariable int pageNum,
                                @PathVariable String factory,
                                @PathVariable String startDate,
                                @PathVariable String endDate) {
        if ("1".equals(factory)) {
            factory = null;
        }
        return iSaleCountService.findByPage(pageNum, factory, LocalDate.parse(startDate), LocalDate.parse(endDate));
    }
}
